package com.lagou.client;

import com.lagou.service.UserService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 客户端端启动器
 */
@Component
public class ClientStarter implements ApplicationRunner {
    /**
     * 上下文初始化完成后启动服务
     *
     * @param args
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        RpcConsumer rpcConsumer = new RpcConsumer();
        UserService proxy = rpcConsumer.createProxy(UserService.class);
        while (true) {
            Thread.sleep(2000);
            System.out.println(proxy.sayHello("Hello!!!"));
        }
    }
}
